﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using IM.Interfaces;
using System.Runtime.Serialization;
using IM.Interfaces.Protocols;

namespace IM.Protocols.MSN
{
    public partial class Settings : UserControl, IProtocolSettings
    {
        public Settings()
        {
            InitializeComponent();
        }

        public bool Validate()
        {
            bool suceed = !String.IsNullOrEmpty(txtLogin.Text);
            suceed &= !String.IsNullOrEmpty(txtPassword.Text);

            return suceed;
        }

        public void SetSettingsData(Object data)
        {
            SettingsData setData = data as SettingsData;

            this.txtLogin.Text = setData.Login;
            this.txtPassword.Text = setData.Password;
            this.chckIsEnabled.Enabled = setData.Enabled;
        }

        public Object GetSettingsData(Object protocolCurrentSettings)
        {
            SettingsData data = new SettingsData(this.txtLogin.Text, this.txtPassword.Text);
            data.Enabled = this.chckIsEnabled.Enabled;
            return data as Object;
        }

        public Type GetSettingsDataType()
        {
            return typeof(SettingsData);
        }

        public Control GetSettingsControl()
        {
            return this;
        }

    }
}
